using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Configuration;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Controls_temp_LifecycleGraphics : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strLC = Request.QueryString["LC"].ToString();
        string strStatus = Request.QueryString["Status"].ToString();

        strLC = Server.HtmlEncode(strLC);
        if (strStatus == "green" || strStatus == "red")
        {
            LoadLCGraphic(strLC, strStatus);
        }

    }
    private bool ThumbnailCallback()
    {
        return false;
    }
    private void LoadLCGraphic(string strLC, string status)
    {
        Bitmap objBitmap;
        Graphics objGraphics;
        string imgURL = Server.MapPath("../images/" + status + "LC.jpg");
        // Create string to draw.
        String drawString = strLC;

        // Create font and brush.
        Font drawFont = new Font("Tahoma", 6);
        SolidBrush drawBrush = new SolidBrush(Color.White);
        SolidBrush drawBrush2 = new SolidBrush(Color.Black);

        // Create point for upper-left corner of drawing.
        PointF drawPoint = new PointF(6, 26);
        PointF drawPoint2 = new PointF(5, 25);

        objBitmap = new Bitmap(imgURL);

        System.Drawing.Image fullSizeImg;
        fullSizeImg = new Bitmap(imgURL);
        using (System.Drawing.Image imgName = fullSizeImg.GetThumbnailImage(100, 75, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero))
        {
            objGraphics = Graphics.FromImage(imgName);
            objGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            objGraphics.DrawString(drawString, drawFont, drawBrush, drawPoint);
            objGraphics.DrawString(drawString, drawFont, drawBrush2, drawPoint2);
            Response.ContentType = "image/jpeg";
            // emit it to the response stream,
            imgName.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            imgName.Dispose();
        }
        drawBrush.Dispose();
        drawBrush2.Dispose();
        drawFont.Dispose();
        fullSizeImg.Dispose();
        objGraphics.Dispose();
        objBitmap.Dispose();

    }

}
